package kjx_test_security.auth;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.extra.spring.SpringUtil;
import kjx_test_security.auth.entity.KcAuthUserModel;
import kjx_test_security.tools.SecurityUtils;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;



import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Service;

/**
 * TODO
 *
 * @Author 康1919
 * @Date 2024/7/20 15:55
 */
@Service
@Slf4j

public class LoginService   {



    public String login() {

        KcAuthUserModel userInfo=ExampleUser.getExampleUser(false);
        UsernamePasswordAuthenticationToken authenticationToken =
                new UsernamePasswordAuthenticationToken(userInfo.getUsername()
                        , userInfo.getPassword());

        log.info("自定义验证前");
        // 开启自定义验证
        AuthenticationManager authenticationManager= SpringUtil.getBean(AuthenticationManager.class);
        Authentication authenticate =authenticationManager.authenticate(authenticationToken);


        return "123456";
    }

}
